<html><head><link href="../../../css-stylesheets/elucidator/program.css" rel="stylesheet" title="program" type="text/css" /> <title>Source file</title></head><body bgcolor="#ffffff" text="#000000" link="#000000" vlink="#000000"><font size="2"><pre><span class="comment">; =&gt;man/time.sdoc</span><br />
<span class="comment">; The LAML library and programs written by Kurt Normark, Aalborg University, Denmark.
; Copyright (C) 1999  Kurt Normark.
;
; This program is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span><br />

<div class="schemedoc-abstract-comment">;;;; This is the date and time library, on which many LAML facilities rely.
;;;; Time is represented as an integer, which represents the number of seconds since January 1, 1970.
;;;; This library contains functions which translate from seconds to year, month, day, hour, and second. 
;;;; Also the reverse translation is provided for. Besides this, the library provides functions for calculating the weekday and
;;;; the week number.
;;;; Weekday and month names can be returned in either Danish og English, depending on the variable language-preference.
;;;; The language-preference binds at a late time, not loadning time.
;;;; Be aware that you need to modify the variable time-zone-info when summer time (daylight saving time) is started and ended.
;;;; .title Reference Manual of the Time Library</div>
<span class="comment">; main functions: time-decode, second-count and weekday.
;
;
; second-count and time-decode are inverse functions. Example:
; (time-decode (second-count 1998 2 17 10 10 40)) = (1998 2 17 10 10 40)</span><br />
<span class="comment">; Given a number of seconds from January 1 in a base year, say 1900,
; calculate year, month, day, hour, minute and second. The result is
; returned as a list (which may not be the most efficient data structure...).
; Does not take leap seconds into account.</span><br />
<span class="comment">; Example (time-decode 1234567890) = (1939 2 14 0 31 30)</span><br />
<a name="base-year"></a><span class="comment">; take base-year as second count 0</span><br /><a name="base-year"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">base-year</span> 1970)

<div class="schemedoc-section-comment">;;; Time zone and Daylight Saving Time correction.</div>
<a name="time-zone-info"></a><div class="schemedoc-definition-comment">;; Defines the time-zone. We also use this variable to adjust for daylight saving time.
;; This is, however, kind of a hack.
;; How many hours in front relative to Greenwich, England.
;; The US east coast: 5. California 8. Denmark -1.
;; If the encoded time is already corrected on your system, time-zone-info must be 0.</div>
<a name="time-zone-info"></a><span><a href="../time.html#time-zone-info"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">time-zone-info</span> -2)  <span class="comment">; DK Summer time: -2.  DK Winter time: -1.</span><br />

<div class="schemedoc-section-comment">;;; Basic time functions.
;;; According to the conventions used in LAML, the function current-time is assumed to return the current time,
;;; represented as the number of seconds elapsed since January 1, 1970, 00:00:00.
;;; In this section there are functions that encode and decode a number of seconds to and from
;;; a conventional time representation (in terms of year, month, day, hour, minutes, second).</div>
<a name="time-decode"></a><div class="schemedoc-definition-comment">;; Given an integer n, which is the number of second since january 1, 1970,
;; return a list:  (year month day minutes seconds).
;; The opposite function is called second-count</div><a name="time-decode"></a><span><a href="../time.html#time-decode"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(time-decode n)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">year-seconds</span> (<a class="applied-name" href="time-1.html#years-and-seconds" title="time">years-and-seconds</a> (<a class="applied-name" href="time-1.html#encoded-time-zone-correction" title="time">encoded-time-zone-correction</a> n)))
         (<span class="local-name-binding">year</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> year-seconds))
         (<span class="local-name-binding">days-hours-minutes-seconds</span> 
             (<a class="applied-name" href="time-1.html#how-many-days-hours-minutes-seconds" title="time">how-many-days-hours-minutes-seconds</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX325" title="R5RS Scheme form">cadr</a> year-seconds)))
         (<span class="local-name-binding">hours</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#second" title="Manual: general">second</a> days-hours-minutes-seconds))
         (<span class="local-name-binding">minutes</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#third" title="Manual: general">third</a> days-hours-minutes-seconds))
         (<span class="local-name-binding">seconds</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#fourth" title="Manual: general">fourth</a> days-hours-minutes-seconds))
         (<span class="local-name-binding">day-month</span> (<a class="applied-name" href="time-1.html#day-and-month" title="time">day-and-month</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#first" title="Manual: general">first</a> days-hours-minutes-seconds) year))
         (<span class="local-name-binding">day</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#first" title="Manual: general">first</a> day-month))
         (<span class="local-name-binding">month</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#second" title="Manual: general">second</a> day-month)))
     (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> year month day hours minutes seconds)))

<a name="second-count"></a><div class="schemedoc-definition-comment">;; Given date and time in terms of year y, month mo, day d, hour h, minutes mi, and seconds s, caluculate the second count.
;; The second-count function compensates for time zone.
;; The opposite function is called date-time.</div><a name="second-count"></a><span><a href="../time.html#second-count"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(second-count y mo d h mi s)</span>
  <span class="comment">; return the second count given year y, month m, day d, hours h, minutes m and seconds s</span><br /> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> <a class="applied-name" href="time-1.html#time-zone-info" title="time">time-zone-info</a> <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>)
   (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a>
      s
      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> 60 mi )
      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a> h)
      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="applied-name" href="time-1.html#day-number" title="time">day-number</a> d mo y) 1))
      (<a class="applied-name" href="time-1.html#year-contribution" title="time">year-contribution</a> y))))

<a name="time-encode"></a><div class="schemedoc-definition-comment">;; An alias of second-count - encode year, month, day, hour, minutes, and seconds to an integer.
;; .form (time-encode y mo d h mi s)</div><a name="time-encode"></a><span><a href="../time.html#time-encode"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">time-encode</span> <a class="applied-name" href="time-1.html#second-count" title="time">second-count</a>)


<div class="schemedoc-section-comment">;;; Time selectors.
;;; The selectors in this section work on decoded time lists. It means that
;;; the selectors just return a given element from the decoded list representation of time. </div>
<a name="year-of-time"></a><div class="schemedoc-definition-comment">;; Return the year of a decoded time list. An integer greater or equal to 1970.
;; .form (year-of-time decoded-time-list)</div><a name="year-of-time"></a><span><a href="../time.html#year-of-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">year-of-time</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#make-selector-function" title="Manual: general">make-selector-function</a> 1 "year-of-time"))

<a name="month-of-time"></a><div class="schemedoc-definition-comment">;; Return the month of a decoded time list. An integer in the interval 1..12
;; .form (month-of-time decoded-time-list)</div><a name="month-of-time"></a><span><a href="../time.html#month-of-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">month-of-time</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#make-selector-function" title="Manual: general">make-selector-function</a> 2 "month-of-time"))

<a name="day-of-time"></a><div class="schemedoc-definition-comment">;; Return the days of a decoded time list. An integer in the interval 1..31
;; .form (day-of-time decoded-time-list)</div><a name="day-of-time"></a><span><a href="../time.html#day-of-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">day-of-time</span>  (<a class="schemedoc-name" href="../../../lib/man/general.html#make-selector-function" title="Manual: general">make-selector-function</a> 3 "day-of-time"))

<a name="hour-of-time"></a><div class="schemedoc-definition-comment">;; Return the hour of a decoded time list. An integer in the interval 0..23
;; .form (hour-of-time decoded-time-list)</div><a name="hour-of-time"></a><span><a href="../time.html#hour-of-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">hour-of-time</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#make-selector-function" title="Manual: general">make-selector-function</a> 4 "hour-of-time"))

<a name="minute-of-time"></a><div class="schemedoc-definition-comment">;; Return the minutes of a decoded time list. An integer in the interval 0..59.
;; .form (minute-of-time decoded-time-list)</div><a name="minute-of-time"></a><span><a href="../time.html#minute-of-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">minute-of-time</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#make-selector-function" title="Manual: general">make-selector-function</a> 5 "minute-of-time"))

<a name="second-of-time"></a><div class="schemedoc-definition-comment">;; Return the seconds of a decoded time list. An integer in the interval 0..59.
;; .form (seconds-of-time decoded-time-list)</div><a name="second-of-time"></a><span><a href="../time.html#second-of-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">second-of-time</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#make-selector-function" title="Manual: general">make-selector-function</a> 6 "second-of-time"))


<span class="comment">; ---------------------------------------------------------------------------------------------------------------</span><br /><div class="schemedoc-section-comment">;;; Week days.
;;; The functions in this section deal with week days. Both English and Danish week day names are supported
;;; via use of the variable language-preference in laml-fundamental.scm.</div>
<span class="comment">; Assume that january the first in the base-year is a thursday.
; In other words, the first weekday in the base year must be (car weekdays)</span><br />
<a name="weekdays"></a><span class="comment">; to maintain backward compatility</span><br /><a name="weekdays"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">weekdays</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a>  "torsdag" "fredag" "l&#248;rdag" "s&#248;ndag" "mandag" "tirsdag" "onsdag"))

<a name="weekdays-danish"></a><span class="comment">; weekday name vectors</span><br /><a name="weekdays-danish"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">weekdays-danish</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a>  "torsdag" "fredag" "l&#248;rdag" "s&#248;ndag" "mandag" "tirsdag" "onsdag"))
<a name="weekdays-english"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">weekdays-english</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a>  "Thursday" "Friday" "Saturday" "Sunday" "Monday" "Tuesday" "Wednesday"))

<a name="brief-weekdays"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">brief-weekdays</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a>  "To" "Fr" "L&#248;" "S&#248;" "Ma" "Ti" "On"))

<a name="brief-weekdays-danish"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">brief-weekdays-danish</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a>  "To" "Fr" "L&#248;" "S&#248;" "Ma" "Ti" "On"))
<a name="brief-weekdays-english"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">brief-weekdays-english</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a>  "Th" "Fr" "Sa" "Su" "Mo" "Tu"  "We"))


<a name="weekday"></a><div class="schemedoc-definition-comment">;; Given an integer, second-count, return the weekday of the time second-count.
;; Returns a string.</div><a name="weekday"></a><span><a href="../time.html#weekday"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(weekday second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">day-number</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> (<a class="applied-name" href="time-1.html#encoded-time-zone-correction" title="time">encoded-time-zone-correction</a> second-count) <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">weekday</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> <a class="applied-name" href="time-1.html#day-number" title="time">day-number</a> 7)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX404" title="R5RS Scheme form">vector-ref</a>  (<a class="applied-name" href="time-1.html#weekday-list" title="time">weekday-list</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a>) weekday)))

<a name="brief-weekday"></a><div class="schemedoc-definition-comment">;; Given an integer, second-count, return the weekday as a brief string, of the time second-count.
;; Returns a string.</div><a name="brief-weekday"></a><span><a href="../time.html#brief-weekday"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(brief-weekday second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">day-number</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> (<a class="applied-name" href="time-1.html#encoded-time-zone-correction" title="time">encoded-time-zone-correction</a> second-count) <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">weekday</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> <a class="applied-name" href="time-1.html#day-number" title="time">day-number</a> 7)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX404" title="R5RS Scheme form">vector-ref</a> (<a class="applied-name" href="time-1.html#brief-weekday-list" title="time">brief-weekday-list</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a>) weekday)))

<a name="weekday-list"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(weekday-list language-preference)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> language-preference 'danish) <a class="applied-name" href="time-1.html#weekdays-danish" title="time">weekdays-danish</a>)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> language-preference 'english) <a class="applied-name" href="time-1.html#weekdays-english" title="time">weekdays-english</a>)
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (error "time library: language preference problems"))))

<a name="brief-weekday-list"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(brief-weekday-list language-preference)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> language-preference 'danish) <a class="applied-name" href="time-1.html#brief-weekdays-danish" title="time">brief-weekdays-danish</a>)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> language-preference 'english) <a class="applied-name" href="time-1.html#brief-weekdays-english" title="time">brief-weekdays-english</a>)
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (error "time library: language preference problems"))))


<span class="comment">; ---------------------------------------------------------------------------------------------------------------</span><br /><div class="schemedoc-section-comment">;;; Week number and week day number.
;;; The functions in this section deal with week numbering and, more simple, week day numbering.</div>
<span class="comment">; Rule: Week number one is that week in the year which contains the first thursday</span><br />
<a name="danish-week-number"></a><div class="schemedoc-definition-comment">;; Given a number sc, return the week number in which sc i located.
;; Weeknumbers are treated by means of Danish weeknumber rules</div><a name="danish-week-number"></a><span><a href="../time.html#danish-week-number"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(danish-week-number sc)</span>

  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">td</span> (<a class="applied-name" href="time-1.html#time-decode" title="time">time-decode</a> sc))
         (<span class="local-name-binding">the-day-number</span> (<a class="applied-name" href="time-1.html#day-number" title="time">day-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX325" title="R5RS Scheme form">caddr</a> td) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX325" title="R5RS Scheme form">cadr</a> td) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> td)))
         (<span class="local-name-binding">jan1</span> (<a class="applied-name" href="time-1.html#second-count" title="time">second-count</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> td) 1 1 0 0 0))
         (<span class="local-name-binding">jan1-wd</span> (<a class="applied-name" href="time-1.html#weekday-number" title="time">weekday-number</a> jan1)) <span class="comment">; monday is weekday 1</span><br />         (<span class="local-name-binding">wn</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> the-day-number (<a class="applied-name" href="time-1.html#week-number-offset" title="time">week-number-offset</a> jan1-wd)) 7))
        )
    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> 0 wn) (<a class="applied-name" href="time-1.html#danish-week-number" title="time">danish-week-number</a> (<a class="applied-name" href="time-1.html#second-count" title="time">second-count</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> td) 1) 12 31 0 0 0))) <span class="comment">; the same the week number of last day in previous year</span><br />          ((<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> wn 53) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX238" title="R5RS Scheme form">&lt;=</a> (<a class="applied-name" href="time-1.html#weekday-number" title="time">weekday-number</a> sc) 3)) 1)  <span class="comment">; not OK yet. We may choose to live with week 53 and some errors here</span><br />          (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> wn))
))

<a name="week-number-offset"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(week-number-offset jan-1-day-number)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 1) 6)  <span class="comment">; monday</span><br />        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 2) 7)  <span class="comment">; tuesday</span><br />        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 3) 8)  <span class="comment">; ...</span><br />        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 4) 9)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 5) 3)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 6) 4)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> jan-1-day-number 7) 5)))

<a name="weekday-number"></a><div class="schemedoc-definition-comment">;; return the weekday-number of second-count (an integer). Monday is day number 1 in the week, sunday is day number 7.</div><a name="weekday-number"></a><span><a href="../time.html#weekday-number"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(weekday-number second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">day-number</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> (<a class="applied-name" href="time-1.html#encoded-time-zone-correction" title="time">encoded-time-zone-correction</a> second-count) <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">weekday-number-thurday-0</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> <a class="applied-name" href="time-1.html#day-number" title="time">day-number</a> 7)))  <span class="comment">; 0 = thursday</span><br />    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 0) 4)
          ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 1) 5)
          ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 2) 6)
          ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 3) 7)
          ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 4) 1)
          ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 5) 2)
          ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> weekday-number-thurday-0 6) 3))))



<span class="comment">; ---------------------------------------------------------------------------------------------------------------</span><br /><div class="schemedoc-section-comment">;;; Time pretty printing.
;;; The functions in this section return pretty printed string representation of time.</div>
<a name="date-time"></a><div class="schemedoc-definition-comment">;; Given an integer, second-cound, return a list of two strings: (date time).
;; This is useful in cases you need to print the data or time as a string.
;; Takes the variable language preference into account.</div><a name="date-time"></a><span><a href="../time.html#date-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(date-time second-count)</span>
 (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">time-list</span> (<a class="applied-name" href="time-1.html#time-decode" title="time">time-decode</a> second-count)))
   (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">year</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#first" title="Manual: general">first</a> time-list))
          (<span class="local-name-binding">month</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#second" title="Manual: general">second</a> time-list))
          (<span class="local-name-binding">day</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#third" title="Manual: general">third</a> time-list))
          (<span class="local-name-binding">hours</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#fourth" title="Manual: general">fourth</a> time-list))
          (<span class="local-name-binding">minutes</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#fifth" title="Manual: general">fifth</a> time-list))
          (<span class="local-name-binding">seconds</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#sixth" title="Manual: general">sixth</a> time-list)))
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a> 'danish) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> 
					     (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a> day) ". " (<a class="applied-name" href="time-1.html#get-month-name" title="time">get-month-name</a> month) " "
							    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a> year))
					     (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="applied-name" href="time-1.html#zero-pad-string" title="time">zero-pad-string</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a>  hours)) ":"
							    (<a class="applied-name" href="time-1.html#zero-pad-string" title="time">zero-pad-string</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a>  minutes)) ":"
							    (<a class="applied-name" href="time-1.html#zero-pad-string" title="time">zero-pad-string</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a>  seconds)))))
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a> 'english) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> 
					     (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="applied-name" href="time-1.html#get-month-name" title="time">get-month-name</a> month) " " (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a> day) ", "
							    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a> year))
					     (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="applied-name" href="time-1.html#zero-pad-string" title="time">zero-pad-string</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a>  hours)) ":"
							    (<a class="applied-name" href="time-1.html#zero-pad-string" title="time">zero-pad-string</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a>  minutes)) ":"
							    (<a class="applied-name" href="time-1.html#zero-pad-string" title="time">zero-pad-string</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX292" title="R5RS Scheme form">number-&gt;string</a>  seconds)))))
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (error "date-time: language preference problems")))
    )))

<a name="date-time-one-string"></a><div class="schemedoc-definition-comment">;; Return a single string that pretty prints the time represented by second count.
;; Takes the variable language preference into account.</div><a name="date-time-one-string"></a><span><a href="../time.html#date-time-one-string"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(date-time-one-string second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">dt</span> (<a class="applied-name" href="time-1.html#date-time" title="time">date-time</a> second-count)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> dt) ", " (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX325" title="R5RS Scheme form">cadr</a> dt))))

<a name="when-generated"></a><div class="schemedoc-definition-comment">;; Return a string that describes the current time as generation time.
;; Takes the variable language-preference into account.
;; .reference "similar function in xhtml1.0-convenience.scm" "when-modified" "xhtml10-convenience.html#when-modified"</div><a name="when-generated"></a><span><a href="../time.html#when-generated"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(when-generated)</span>
 (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">ct</span> (current-time))
        (<span class="local-name-binding">dt</span> (<a class="applied-name" href="time-1.html#date-time" title="time">date-time</a> ct))
        (<span class="local-name-binding">day-of-week</span> (<a class="applied-name" href="time-1.html#weekday" title="time">weekday</a> ct))
        (<span class="local-name-binding">date</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> dt))
        (<span class="local-name-binding">time</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX325" title="R5RS Scheme form">cadr</a> dt))
        (<span class="local-name-binding">init-text</span> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a> 'danish) "Genereret: ")
                         ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a> 'english) "Generated: ")
                         (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (error "when-generated: language preference problems"))))
       ) 
  (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> init-text day-of-week ", " date ", " time)))


<span class="comment">; ---------------------------------------------------------------------------------------------------------------</span><br /><div class="schemedoc-section-comment">;;; Time interval functions.</div>
<a name="time-interval"></a><div class="schemedoc-definition-comment">;; Return the number of years, months, weeks, days, hours, minutes, and seconds from second-count.
;; In this function, months are uniformly counted as 30 days, and a year is counted as 365 days.
;; Due to this, a year is not exactly counted as 12 months, and therefore slightly unexpected results may occur.
;; A list of seven integers is returned.</div><a name="time-interval"></a><span><a href="../time.html#time-interval"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(time-interval second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">years</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> second-count <a class="applied-name" href="time-1.html#seconds-in-a-normal-year" title="time">seconds-in-a-normal-year</a>))
         (<span class="local-name-binding">rest-1</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> second-count <a class="applied-name" href="time-1.html#seconds-in-a-normal-year" title="time">seconds-in-a-normal-year</a>))
         (<span class="local-name-binding">months</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> rest-1 <a class="applied-name" href="time-1.html#seconds-in-a-normal-month" title="time">seconds-in-a-normal-month</a>))
         (<span class="local-name-binding">rest-2</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> rest-1 <a class="applied-name" href="time-1.html#seconds-in-a-normal-month" title="time">seconds-in-a-normal-month</a>))
         (<span class="local-name-binding">weeks</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> rest-2 <a class="applied-name" href="time-1.html#seconds-in-a-week" title="time">seconds-in-a-week</a>))
         (<span class="local-name-binding">rest-3</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> rest-2  <a class="applied-name" href="time-1.html#seconds-in-a-week" title="time">seconds-in-a-week</a>))
         (<span class="local-name-binding">days</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> rest-3 <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">rest-4</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> rest-3 <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">hours</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> rest-4 <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>))
         (<span class="local-name-binding">rest-5</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> rest-4 <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>))
         (<span class="local-name-binding">minutes</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> rest-5 60))
         (<span class="local-name-binding">seconds</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> rest-5 60)))
   (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> years months weeks days hours minutes seconds)))

<a name="present-time-interval"></a><div class="schemedoc-definition-comment">;; Return a string which presens the number of years, months, weeks, days, hours, minutes, and seconds
;; of second-count</div><a name="present-time-interval"></a><span><a href="../time.html#present-time-interval"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(present-time-interval second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">ti</span> (<a class="applied-name" href="time-1.html#time-interval" title="time">time-interval</a> second-count))
         (<span class="local-name-binding">y</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#first" title="Manual: general">first</a> ti))
         (<span class="local-name-binding">mo</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#second" title="Manual: general">second</a> ti))
         (<span class="local-name-binding">w</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#third" title="Manual: general">third</a> ti))
         (<span class="local-name-binding">d</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#fourth" title="Manual: general">fourth</a> ti))
         (<span class="local-name-binding">h</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#fifth" title="Manual: general">fifth</a> ti))
         (<span class="local-name-binding">mi</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#sixth" title="Manual: general">sixth</a> ti))
         (<span class="local-name-binding">s</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#seventh" title="Manual: general">seventh</a> ti)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a>
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> y 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> y) " " "years "))
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> mo 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> mo) " " "months "))
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> w 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> w) " " "weeks "))
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> d 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> d) " " "days "))
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> h 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> h) " " "hours "))
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> mi 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> mi) " " "minutes "))
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> s 0) "" (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> s) " " "seconds "))
    )))



<span class="comment">; ---------------------------------------------------------------------------------------------------------------</span><br /><div class="schemedoc-section-comment">;;; Conventional string representation of time. 
;;; This section contains a number of functions that deal with dates and time as strings in the formats such as "ddmmyyyy" and "hhmm".
;;; The seconds are not part of the string representation.</div>
<a name="transform-year-month-day-hour-minutes-strings"></a><div class="schemedoc-definition-comment">;; Transform date and time strings to a second count (a large integer number of seconds elapsed since january 1, 1970).
;; The date parameter is a string of the form "ddmmyyyy" (eight ciffers).
;; The time parameter is of the form "hhmm" (four ciffers).
;; Assumes as a prefix that date and time represent a legal point in time. Use date-ok? and time-ok? to assure this.
;; Return #f if date is blank (or if both date and time is blank).</div><a name="transform-year-month-day-hour-minutes-strings"></a><span><a href="../time.html#transform-year-month-day-hour-minutes-strings"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(transform-year-month-day-hour-minutes-strings date time)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="schemedoc-name" href="../../../lib/man/general.html#blank-string?" title="Manual: general">blank-string?</a> date) #f)
        ((<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#blank-string?" title="Manual: general">blank-string?</a> time) (<a class="schemedoc-name" href="../../../lib/man/general.html#numeric-string?" title="Manual: general">numeric-string?</a> date)) 
          (<a class="applied-name" href="time-1.html#second-count" title="time">second-count</a> (<a class="applied-name" href="time-1.html#four-ciffer-number" title="time">four-ciffer-number</a> date 2) (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> date 2) (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> date 1) 0 0 0))
        ((<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#numeric-string?" title="Manual: general">numeric-string?</a> date) (<a class="schemedoc-name" href="../../../lib/man/general.html#numeric-string?" title="Manual: general">numeric-string?</a> time))
          (<a class="applied-name" href="time-1.html#second-count" title="time">second-count</a> (<a class="applied-name" href="time-1.html#four-ciffer-number" title="time">four-ciffer-number</a> date 2) (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> date 2) (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> date 1)
                        (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> time 1) (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> time 2) 0))
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (error "transform-year-month-day-hour-minutes-string: date or time string is illegal"))))

<a name="date-string"></a><div class="schemedoc-definition-comment">;; Return the date, in the format "ddmmyyyy" of second-count,
;; which represents the time in seconds elapsed since January 1, 1970.</div><a name="date-string"></a><span><a href="../time.html#date-string"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(date-string second-count)</span>
 (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">decoding</span> (<a class="applied-name" href="time-1.html#time-decode" title="time">time-decode</a> second-count))
        (<span class="local-name-binding">y-string</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#first" title="Manual: general">first</a> decoding)))
        (<span class="local-name-binding">m-string</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#second" title="Manual: general">second</a> decoding)))
        (<span class="local-name-binding">d-string</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#third" title="Manual: general">third</a> decoding)))
        (<span class="local-name-binding">m-string-1</span> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX236" title="R5RS Scheme form">&lt;</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> m-string) 2) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> "0" m-string) m-string))
        (<span class="local-name-binding">d-string-1</span> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX236" title="R5RS Scheme form">&lt;</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> d-string) 2) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> "0" d-string) d-string)))
   (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> d-string-1 m-string-1 y-string)))

<a name="time-string"></a><div class="schemedoc-definition-comment">;; Return the date, in the format "ddmmyyyy" of second-count,
;; which represents the time in seconds elapsed since January 1, 1970.</div><a name="time-string"></a><span><a href="../time.html#time-string"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(time-string second-count)</span>
 (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">decoding</span> (<a class="applied-name" href="time-1.html#time-decode" title="time">time-decode</a> second-count))
        (<span class="local-name-binding">h-string</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#fourth" title="Manual: general">fourth</a> decoding)))
        (<span class="local-name-binding">m-string</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-string" title="Manual: general">as-string</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#fifth" title="Manual: general">fifth</a> decoding)))
        (<span class="local-name-binding">h-string-1</span> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX236" title="R5RS Scheme form">&lt;</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> h-string) 2) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> "0" h-string) h-string))
        (<span class="local-name-binding">m-string-1</span> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX236" title="R5RS Scheme form">&lt;</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> m-string) 2) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> "0" m-string) m-string)))
   (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> h-string-1 m-string-1)))

<a name="two-ciffer-number"></a><span class="comment">; Extract a two ciffer number n of str. Outputs an integer between 0 and 99.
; Assume as a precondtion that string is long enough and purely numeric (integer).
; Example: (two-ciffer-number "123465" 1) = 12.  (two-ciffer-number "123465" 3) = 65.</span><br /><a name="two-ciffer-number"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(two-ciffer-number str n)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">pos</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> n 2) 2))
         (<span class="local-name-binding">c1</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX379" title="R5RS Scheme form">string-ref</a> str pos)) 48)) <span class="comment">; ciffer value 1</span><br />         (<span class="local-name-binding">c2</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX379" title="R5RS Scheme form">string-ref</a> str (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> pos 1))) 48)) <span class="comment">; ciffer value 2</span><br />       )
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> c1 10) c2)))

<a name="four-ciffer-number"></a><span class="comment">; Extract a four ciffer number n of str. Outputs an integer between 0 and 9999.
; As two-ciffer-number, but now with four ciffers</span><br /><a name="four-ciffer-number"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(four-ciffer-number str n)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">pos</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> n 4) 4))
         (<span class="local-name-binding">c1</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX379" title="R5RS Scheme form">string-ref</a> str pos)) 48)) <span class="comment">; ciffer value 1</span><br />         (<span class="local-name-binding">c2</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX379" title="R5RS Scheme form">string-ref</a> str (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> pos 1))) 48)) <span class="comment">; ciffer value 2</span><br />         (<span class="local-name-binding">c3</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX379" title="R5RS Scheme form">string-ref</a> str (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> pos 2))) 48)) <span class="comment">; ciffer value 3</span><br />         (<span class="local-name-binding">c4</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX379" title="R5RS Scheme form">string-ref</a> str (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> pos 3))) 48)) <span class="comment">; ciffer value 4</span><br />       )
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> c1 1000) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> c2 100) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> c3 10) c4)))

<a name="date-ok?"></a><div class="schemedoc-definition-comment">;; Return whether x is a legal date string (of the form "ddmmyyyy").
;; Exact determination, including february and leap years.
;; Uses days-in-month from the time library.</div><a name="date-ok?"></a><span><a href="../time.html#date-ok?"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(date-ok? x)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="schemedoc-name" href="../../../lib/man/general.html#blank-string?" title="Manual: general">blank-string?</a> x) #t)
        ((<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#numeric-string?" title="Manual: general">numeric-string?</a> x) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> 8 (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> x)))
          (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">d</span> (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> x 1))
		(<span class="local-name-binding">m</span> (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> x 2))
		(<span class="local-name-binding">y</span> (<a class="applied-name" href="time-1.html#four-ciffer-number" title="time">four-ciffer-number</a> x 2)))
	    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX239" title="R5RS Scheme form">&gt;=</a> m 1) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX238" title="R5RS Scheme form">&lt;=</a> m 12)
		 (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX239" title="R5RS Scheme form">&gt;=</a> d 1) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX238" title="R5RS Scheme form">&lt;=</a> d (<a class="applied-name" href="time-1.html#days-in-month" title="time">days-in-month</a> m y)))))
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> #f)))

<a name="time-ok?"></a><div class="schemedoc-definition-comment">;; Return whether x is a legal time string (of the form "hhmm")</div><a name="time-ok?"></a><span><a href="../time.html#time-ok?"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(time-ok? x)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="schemedoc-name" href="../../../lib/man/general.html#blank-string?" title="Manual: general">blank-string?</a> x) #t)
        ((<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#numeric-string?" title="Manual: general">numeric-string?</a> x) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> 4 (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> x)))
          (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">h</span> (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> x 1))
		(<span class="local-name-binding">m</span> (<a class="applied-name" href="time-1.html#two-ciffer-number" title="time">two-ciffer-number</a> x 2)))
	    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX117" title="R5RS Scheme form">and</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX239" title="R5RS Scheme form">&gt;=</a> h 0) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX238" title="R5RS Scheme form">&lt;=</a> h 23)
		 (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX239" title="R5RS Scheme form">&gt;=</a> m 0) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX238" title="R5RS Scheme form">&lt;=</a> m 59))))
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> #f)))


<a name="hours-minutes-decode-string"></a><div class="schemedoc-definition-comment">;; Decode a string of the form "h:m" or "h.m" to a list of the form (h m).
;; Does also accept the juxtaposition "hm" in which case m is taken as the last two ciffers.
;; Given for instance "12:35", "12.35" or "1235" return (12 35).</div><a name="hours-minutes-decode-string"></a><span><a href="../time.html#hours-minutes-decode-string"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(hours-minutes-decode-string hour-minute-string)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">div-pos-colon</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#find-in-string" title="Manual: general">find-in-string</a> hour-minute-string #\:))
        (<span class="local-name-binding">div-pos-point</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#find-in-string" title="Manual: general">find-in-string</a> hour-minute-string #\.)))
    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> (div-pos-colon
            (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">res-1</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> hour-minute-string 0 div-pos-colon)))
		  (<span class="local-name-binding">res-2</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> hour-minute-string (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> div-pos-colon 1) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> hour-minute-string)))))
	      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> res-1 res-1 0)
		    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> res-2 res-2 0))))
          (div-pos-point
            (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">res-1</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> hour-minute-string 0 div-pos-point)))
		  (<span class="local-name-binding">res-2</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> hour-minute-string (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> div-pos-point 1) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> hour-minute-string)))))
	      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> res-1 res-1 0)
		    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> res-2 res-2 0))))
          ((<a class="schemedoc-name" href="../../../lib/man/general.html#numeric-string?" title="Manual: general">numeric-string?</a> hour-minute-string)
            (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">hour-minute-number</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> hour-minute-string)))
              (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> hour-minute-number 100) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX259" title="R5RS Scheme form">remainder</a> hour-minute-number 100))))
          (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#laml-error" title="Manual: general">laml-error</a> "hours-minutes-decode-string: Cannot decode string" hour-minute-string)))))



<a name="year-month-day-decode-string"></a><div class="schemedoc-definition-comment">;; Decode a string of the form "y-m-d" to a list of the form (y m d). A proper list of three integers.
;; Given for instance "2005-9-12", return the list (2005 9 12) representing September 12, 2005.</div><a name="year-month-day-decode-string"></a><span><a href="../time.html#year-month-day-decode-string"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(year-month-day-decode-string year-month-day-string)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">div-pos-1</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#find-in-string" title="Manual: general">find-in-string</a> year-month-day-string #\-))
         (<span class="local-name-binding">div-pos-2</span> (<a class="schemedoc-name" href="../../../lib/man/general.html#find-in-string" title="Manual: general">find-in-string</a> year-month-day-string #\- (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> div-pos-1 1))))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> year-month-day-string 0 div-pos-1))
          (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> year-month-day-string (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> 1 div-pos-1) div-pos-2)) 
          (<a class="schemedoc-name" href="../../../lib/man/general.html#as-number" title="Manual: general">as-number</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX391" title="R5RS Scheme form">substring</a> year-month-day-string (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> div-pos-2 1) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> year-month-day-string))))))


<span class="comment">; ---------------------------------------------------------------------------------------------------------------</span><br /><div class="schemedoc-section-comment">;;; Underlying time related constants and functions.
;;; In this section there is a number of auxiliary time functions.
;;; In addition, we document a number of time related constants.</div>
<a name="seconds-in-a-normal-year"></a><div class="schemedoc-definition-comment">;; The number of seconds in a non-leap year.</div><a name="seconds-in-a-normal-year"></a><span><a href="../time.html#seconds-in-a-normal-year"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">seconds-in-a-normal-year</span> 31536000)

<a name="seconds-in-a-leap-year"></a><div class="schemedoc-definition-comment">;; The number of seconds in a leap year.</div><a name="seconds-in-a-leap-year"></a><span><a href="../time.html#seconds-in-a-leap-year"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">seconds-in-a-leap-year</span> 31622400)

<a name="seconds-in-a-normal-month"></a><div class="schemedoc-definition-comment">;; The number of seconds in a 30-day month.</div><a name="seconds-in-a-normal-month"></a><span><a href="../time.html#seconds-in-a-normal-month"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">seconds-in-a-normal-month</span> 2592000)

<a name="seconds-in-a-week"></a><div class="schemedoc-definition-comment">;; The number of seconds in a week.</div><a name="seconds-in-a-week"></a><span><a href="../time.html#seconds-in-a-week"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">seconds-in-a-week</span> 604800)

<a name="seconds-in-a-day"></a><div class="schemedoc-definition-comment">;; The number of seconds in a day.</div><a name="seconds-in-a-day"></a><span><a href="../time.html#seconds-in-a-day"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">seconds-in-a-day</span> 86400)

<a name="seconds-in-an-hour"></a><div class="schemedoc-definition-comment">;; The number of seconds in an hour.</div><a name="seconds-in-an-hour"></a><span><a href="../time.html#seconds-in-an-hour"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">seconds-in-an-hour</span> 3600)

<a name="month-length-normal-year"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">month-length-normal-year</span>
  (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a> 31 28 31 30 31 30 31 31 30 31 30 31))


<a name="month-name"></a><span class="comment">; a month name vector, to maintain backward compatibility</span><br /><a name="month-name"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">month-name</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a> "Januar" "Februar" "Marts" "April" "Maj" "Juni" "Juli" "August" "September"
                                                     "Oktober" "November" "December"))


<a name="month-name-danish"></a><span class="comment">; month name vectors</span><br /><a name="month-name-danish"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">month-name-danish</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a> "Januar" "Februar" "Marts" "April" "Maj" "Juni" "Juli" "August" "September"
                                                     "Oktober" "November" "December"))

<a name="month-name-english"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">month-name-english</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX402" title="R5RS Scheme form">vector</a> "January" "February" "March" "April" "May" "June" "July" "August" "September"
                                                     "October" "November" "December"))

<a name="get-month-name"></a><div class="schemedoc-definition-comment">;; Return the month name of month-number. January is number one.
;; The result depends on the free variable language-preference.
;; .reference "applied variable" "language-preference" "../../man/laml.html#language-preference"</div><a name="get-month-name"></a><span><a href="../time.html#get-month-name"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(get-month-name month-number)</span>
 (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX404" title="R5RS Scheme form">vector-ref</a>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a> 'danish) <a class="applied-name" href="time-1.html#month-name-danish" title="time">month-name-danish</a>)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX199" title="R5RS Scheme form">eq?</a> <a class="schemedoc-name" href="../../../man/laml.html#language-preference" title="Manual: laml">language-preference</a> 'english) <a class="applied-name" href="time-1.html#month-name-english" title="time">month-name-english</a>)
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> (error "time library: language preference problems")))
  (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> month-number 1)
  ))

<a name="leap-year"></a><div class="schemedoc-definition-comment">;; Return whether y is a leap year.</div><a name="leap-year"></a><span><a href="../time.html#leap-year"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(leap-year y)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">cond</a> ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> y 400) 0) #t)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> y 100) 0) #f)
        ((<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> y 4) 0) #t)
        (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX110" title="R5RS Scheme form">else</a> #f)))

<a name="years-and-seconds"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(years-and-seconds n)</span>
  (<a class="applied-name" href="time-1.html#cycle-years" title="time">cycle-years</a> 0 <a class="applied-name" href="time-1.html#base-year" title="time">base-year</a> n))

<a name="cycle-years"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(cycle-years n year u)</span>
<span class="comment">; The second count January 1, 00:00 in year is n. Go to next year if u
; is not in year. Return if u is in year.
; In this case return (list year u)</span><br />  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">year-length</span> (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="applied-name" href="time-1.html#leap-year" title="time">leap-year</a> year)
                          <a class="applied-name" href="time-1.html#seconds-in-a-leap-year" title="time">seconds-in-a-leap-year</a>
                          <a class="applied-name" href="time-1.html#seconds-in-a-normal-year" title="time">seconds-in-a-normal-year</a>)))
    (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX236" title="R5RS Scheme form">&lt;</a> u year-length) 
        (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> year u)
        (<a class="applied-name" href="time-1.html#cycle-years" title="time">cycle-years</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> n year-length) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> 1 year) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> u year-length)))))

<a name="day-and-month"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(day-and-month day-count year)</span>
<span class="comment">; Day-count is a number of days in a year. Return the list (day-in-month month-number)</span><br />  (<a class="applied-name" href="time-1.html#day-and-month-help" title="time">day-and-month-help</a> 0 1 year (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> 1 day-count)) )

<a name="day-and-month-help"></a><span class="comment">; about (+ 1 day-count):  One day into the year is january 2, NOT january 1.</span><br />

<a name="day-and-month-help"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(day-and-month-help n m y c)</span>
<span class="comment">; We have counted n days at the beginning of the first day in month m in year y</span><br />  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX238" title="R5RS Scheme form">&lt;=</a> c (<a class="applied-name" href="time-1.html#days-in-month" title="time">days-in-month</a> m y)) 
      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> c m)
      (<a class="applied-name" href="time-1.html#day-and-month-help" title="time">day-and-month-help</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> n (<a class="applied-name" href="time-1.html#days-in-month" title="time">days-in-month</a> m y)) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> m 1)
                          y (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> c (<a class="applied-name" href="time-1.html#days-in-month" title="time">days-in-month</a> m y)))))

<a name="days-in-month"></a><div class="schemedoc-definition-comment">;; Return the number of days in month and year</div><a name="days-in-month"></a><span><a href="../time.html#days-in-month"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(days-in-month month year)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> month 2)
      (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="applied-name" href="time-1.html#leap-year" title="time">leap-year</a> year) 29 28)
      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX404" title="R5RS Scheme form">vector-ref</a> <a class="applied-name" href="time-1.html#month-length-normal-year" title="time">month-length-normal-year</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> month 1))))
  

<a name="how-many-days-hours-minutes-seconds"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(how-many-days-hours-minutes-seconds n)</span>
<span class="comment">; Return the number days, hours, minutes and seconds in second count n.
; n is less than the number of seconds in a year</span><br />  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">days</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> n <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">n-rest-1</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> n <a class="applied-name" href="time-1.html#seconds-in-a-day" title="time">seconds-in-a-day</a>))
         (<span class="local-name-binding">hours</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> n-rest-1 <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>))
         (<span class="local-name-binding">n-rest-2</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> n-rest-1 <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>))
         (<span class="local-name-binding">minutes</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> n-rest-2 60))
         (<span class="local-name-binding">seconds</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX260" title="R5RS Scheme form">modulo</a> n-rest-2 60)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> days hours minutes seconds)))

                
<a name="encoded-time-zone-correction"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(encoded-time-zone-correction n)</span>
  (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> n (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX251" title="R5RS Scheme form">-</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a> <a class="applied-name" href="time-1.html#time-zone-info" title="time">time-zone-info</a>))))


<a name="zero-pad-string"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(zero-pad-string str)</span>
 (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> 1 (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX378" title="R5RS Scheme form">string-length</a> str)) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX392" title="R5RS Scheme form">string-append</a> "0" str) str))





<a name="day-number"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(day-number d m y)</span>
 <span class="comment">; Return the day number of day d in month m in the year y. January 1 is day one.</span><br /> (<a class="applied-name" href="time-1.html#day-count" title="time">day-count</a> 0 1 d m y))

<a name="day-count"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(day-count dc mc d m y)</span>
  <span class="comment">; the tail recursive counter function for day-number</span><br />  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> mc m)
      (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> dc d)
      (<a class="applied-name" href="time-1.html#day-count" title="time">day-count</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> dc (<a class="applied-name" href="time-1.html#days-in-month" title="time">days-in-month</a> mc y)) (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> mc 1) d m y)))

<a name="year-contribution"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(year-contribution y)</span>
  <span class="comment">; return the number of seconds from (and including) the base year until
; but not including the year y</span><br />  (<a class="applied-name" href="time-1.html#year-counter" title="time">year-counter</a> 0 <a class="applied-name" href="time-1.html#base-year" title="time">base-year</a> y))

<a name="year-counter"></a><span></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(year-counter sc yc y)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX235" title="R5RS Scheme form">=</a> yc y)
      sc
      (<a class="applied-name" href="time-1.html#year-counter" title="time">year-counter</a>
          (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> sc (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX103" title="R5RS Scheme form">if</a> (<a class="applied-name" href="time-1.html#leap-year" title="time">leap-year</a> yc) <a class="applied-name" href="time-1.html#seconds-in-a-leap-year" title="time">seconds-in-a-leap-year</a> <a class="applied-name" href="time-1.html#seconds-in-a-normal-year" title="time">seconds-in-a-normal-year</a>))
          (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> yc 1)
          y)))


<a name="hours-minutes-seconds-decode"></a><div class="schemedoc-definition-comment">;; Return a list of (hours minutues seconds) given an integer second-count.</div><a name="hours-minutes-seconds-decode"></a><span><a href="../time.html#hours-minutes-seconds-decode"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(hours-minutes-seconds-decode second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">hours</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> second-count <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>))
         (<span class="local-name-binding">rest</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX259" title="R5RS Scheme form">remainder</a>  second-count <a class="applied-name" href="time-1.html#seconds-in-an-hour" title="time">seconds-in-an-hour</a>))
         (<span class="local-name-binding">minutes</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> rest 60))
         (<span class="local-name-binding">seconds</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX259" title="R5RS Scheme form">remainder</a> rest 60)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> hours minutes seconds)))


<div class="schemedoc-section-comment">;;; Other time related functions.</div>
<a name="emacs-lisp-time-to-second-count"></a><div class="schemedoc-definition-comment">;; Given time-list, which is Emacs' representation of Universal time, return a single (large) integer that represents universal time.
;; .parameter time-list A list of three 16 bit integers (high low microsec) which represents a point in time after 1969. 
;; .returns high * 2**16 + low</div><a name="emacs-lisp-time-to-second-count"></a><span><a href="../time.html#emacs-lisp-time-to-second-count"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(emacs-lisp-time-to-second-count time-list)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX121" title="R5RS Scheme form">let</a> ((<span class="local-name-binding">high</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX321" title="R5RS Scheme form">car</a> time-list))
        (<span class="local-name-binding">low</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX325" title="R5RS Scheme form">cadr</a> time-list)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX249" title="R5RS Scheme form">+</a> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX250" title="R5RS Scheme form">*</a> high (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX281" title="R5RS Scheme form">expt</a> 2 16)) low)))

<a name="second-count-to-emacs-lisp-time"></a><div class="schemedoc-definition-comment">;; Given a second count, which represents a point in time as a single large integer, return a list of three 16 bit numbers that corresponds to Emacs's representation.
;; .parameter second-count An integer - the number of seconds elapsed since Jan 1, 1970.
;; .returns A list of three 16 bit integers (high low 0), for which high * 2**16 + low = second-count.</div><a name="second-count-to-emacs-lisp-time"></a><span><a href="../time.html#second-count-to-emacs-lisp-time"><img src="../../../images/elucidator/small-prev.gif" title="SchemeDoc Manual entry" alt="" border="0" /></a> <br /></span>(<a class="scheme-syntax-name" href="../../../r5rs/r5rs_7.html#IDX173" title="R5RS Scheme form">define</a> <span class="signature">(second-count-to-emacs-lisp-time second-count)</span>
  (<a class="scheme-syntax-name" href="../../../r5rs/r5rs_6.html#IDX122" title="R5RS Scheme form">let*</a> ((<span class="local-name-binding">two-pow-16</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX281" title="R5RS Scheme form">expt</a> 2 16))
         (<span class="local-name-binding">low</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX259" title="R5RS Scheme form">remainder</a> second-count two-pow-16))
         (<span class="local-name-binding">high</span> (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX258" title="R5RS Scheme form">quotient</a> second-count two-pow-16)))
    (<a class="scheme-procedure-name" href="../../../r5rs/r5rs_8.html#IDX332" title="R5RS Scheme form">list</a> high low 0)))</pre></font><div>&nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p> &nbsp; <p></p></div></body></html>